﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace QuanLyDatVe.DataAccessLayer
{
    public class ConnectDatabase
    {
        private SqlConnection sqlConnect;

        public SqlConnection SqlConnect
        {
            get { return sqlConnect; }
        }

        public ConnectDatabase()
        {
                sqlConnect = new SqlConnection();
                sqlConnect.ConnectionString = AppConfig.ConnectionString;
        }
          
        public void OpenDatabase()
        {
            if (sqlConnect == null || sqlConnect.State == ConnectionState.Closed)
            {
                sqlConnect.Open();
                
            }
        }

        public void CloseDatabase()
        {
            if (sqlConnect.State == ConnectionState.Open)
            {
                sqlConnect.Close();
            }
        }
    }
}
